[pdpyras] How to filter incidents by incident number using

I can see there’s an example here: https://pagerduty.github.io/pdpyras/

I’m using Python here (PDpyras).

I was able to filter out PD incidents by statuses, etc but I’d like retrieve a single incident. However, I don’t understand this “params” option and I haven’t found anything out there with all the parameters I can use to filter out the incidents.

I’d like to do something like this:

async def get_pd_incident_from_message(incident_number):
    api_token = 'MY_TOKEN'
    session = APISession(api_token)

    # Query incidents
    incidents = session.list_all(
        'incidents',
        params={'incident_number': incident_number}
    )

But obviously this is a “made up” params. Can you guys help me getting the correct syntax so I can retrieve only incident_number XXXX? Many thanks.

I found the answer myself for those interested using “get”:

async def get_pd_incident_from_message(incident_number):
    api_token = YOUR_TOKEN'
    session = APISession(api_token)
    incident = session.get(url=f'incidents/{incident_number}').json()
    return incident
1 Like

Hi Rodrigo,

Thanks for sharing your find! If you’d like to visit the GitHub repo for PagerDuty’s pdpyras - its available here: https://github.com/PagerDuty/pdpyras

Cheers,
Abbott